/**
@author		Jong Min, Lee
@date		  02/11/2014
@breif		study work space class

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#include "stdafx.h"
#include "Taurus_Viewer/StudyWorkSpace.h"

#include "Taurus_DcmData/StudySet.h"
#include "Taurus_Viewer/StudyViewController.h"
#include "Taurus_Viewer/StudySetPool.h"
#include "Taurus_Viewer/StudyViewStyle.h"

unsigned int CStudyWorkSpace::theBaseUID = 0;

CStudyWorkSpace::CStudyWorkSpace()
  : theUniqueID(theBaseUID++)
  , theStudySet(NULL)
  , theViewController(NULL)
  , theState(0)
  , theNormalPosition(0, 0, 0, 0)
{}

CStudyWorkSpace::~CStudyWorkSpace()
{
  if(theViewController != NULL)
    _DELETE(theViewController);

  if(theStudySet != NULL)
  {
    CStudySetPool* theStudySetPool = CStudySetPool::getInstance();
    theStudySetPool->removeStudySet(theStudySet);
  }
}

DWORD CStudyWorkSpace::setFocus(BOOL focus, BOOL redraw)
{
  if(focus)
    theState |= SWS_HAS_FOCUS;
  else
    theState &= ~SWS_HAS_FOCUS;

  COLORREF bkClr, textClr;
  if(focus)
    CStudyViewStyle::getFocusedTitleBarClr(bkClr, textClr);
  else
    CStudyViewStyle::getNormalTitleBarClr(bkClr, textClr);

  if(theViewController != NULL)
    theViewController->setTitlebarColor(bkClr, textClr, redraw);

  return ERROR_SUCCESS;
}
